<%@page import="org.json.JSONObject"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="ee.battleship.classes.Player"%>
<% Player player = (Player) session.getAttribute("player"); %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>Laevade pommitamine</title>
	<link rel="stylesheet" type="text/css" href="js/lib/fancybox/jquery.fancybox-1.3.4.css" media="screen" />
	<link rel="stylesheet" type="text/css" href="gfx/styles.css" />
	<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
	<script type="text/javascript" src="js/lib/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
	<script type="text/javascript" src="js/gui.js"></script>
	<script type="text/javascript" src="js/ajax.js"></script>
	
</head>
<body>
<div id="wrapper">
	<div id="header">
		<h1>
			<a href="Index" title="Laevade pommitamise">Laevade pommitamine</a>
		</h1>
		<div id="menu">
			<div class="user">Tere, <span class="bold"><%= player.getName() %></span>!</div>
			<ul style="display: inline-block">
				<li><a href="javascript:void(0)" class="replay">Kordused</a></li>
				<li><a href="leaderboard.jsp" class="leaderboard">Edetabel</a></li>
				<li><a href="javascript:void(0);" class="help">Abi</a></li>
				<li><a href="UserLogout" class="special">Logi välja</a></li>
			</ul>
		</div>
	</div>
	<div id="game">
		<div class="col-left">
			<div id="lobby">
				<div class="title">Käimasolevad mängud</div>
				<div class="gameList">
					<ul id="gameList">
					</ul>
				</div>
			</div>
		</div>
		<div class="col-center">
			<div class="announcement">
				<div class="title"><span class="info-icon">Info</span></div>
				<div class="announcement-text">Mängu alustamiseks ühine käimasoleva mänguga vasakul nimekirjas või loo ise uus mäng
				</div>
			</div>
			<div class="start">
				<a href="javascript:void(0)" class="create-game" title="Loo uus mäng">Loo uus mäng</a>
			</div>
		</div>
		<div class="col-right">
			<div id="stats">
				<div class="title">Sinu statistika</div>
				<table class="stats-table">
					<tr>
						<th>Võidud:</th>
						<td><%= player.getWins() %></td>
					</tr>
					<tr>
						<th>Kaotused:</th>
						<td><%= player.getLosses() %></td>
					</tr>
					<tr>
						<th>Võitude ja kaotuste suhe:</th>
						<% if (player.getWins() != 0) {%>
							<td><% out.print((player.getWins() - player.getLosses()) / player.getWins()); %></td>
						<% } else { %>
							<td>0</td>
						<% }  %>
					</tr>
					<tr>
						<th>Mänge kokku:</th>
						<td><%= player.getPlayedGames() %></td>
					</tr>
				</table>
				
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
	AjaxRequest.init();
	AjaxRequest.getGameList();
</script>
</body>
</html>